using System.Text;

namespace etcetera.Mvc.UI.Toolbar
{
    public class ToolbarButton : ToolbarItem
    {
        private readonly string _linkTitle;
        private readonly string _buttonClass;

        public ToolbarButton(string linkTitle, string actionUrl, string buttonClass)
        {
            _linkTitle = linkTitle;
            _actionUrl = actionUrl;
            _buttonClass = buttonClass;
        }

        public override string GetValue()
        {
            var sb = new StringBuilder();

            sb.AppendFormat("<div class='tBtn {0}' />", _buttonClass);

            if (!string.IsNullOrEmpty(_actionUrl))
                sb.AppendFormat("<a href='{0}' title='{1}'><span/></a>", _actionUrl, _linkTitle);

            sb.AppendLine("</div>");

            return sb.ToString();
        }
    }
}